package com.wujian.love.redis.stream;

import com.wujian.love.redis.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import redis.clients.jedis.StreamEntryID;

import java.util.HashMap;

/**
 * @ClassName: MessageStreamProducerService
 * @Description: 消息的生产者
 * @Author: wuj
 * @Date: 2021-02-03 11:00
 **/
@Service
public class MessageStreamProducerService {

    @Autowired
    private RedisService redisService;

    //业务处理
    public StreamEntryID sendMsg(HashMap<String,String> map , String redisKey){
        //处理消息
        StreamEntryID entryID = redisService.xadd(redisKey, map);
        //创建消费者组
        redisService.createConsumerGroup(redisKey, entryID);
        return entryID;
    }
}
